package cn.lili.controller.promotion;

import cn.lili.common.security.AuthUser;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.promotion.entity.dos.ReturnActivityUser;
import cn.lili.modules.promotion.service.ReturnActivityUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

@RestController
@Api(tags = "用户全返卷")
@RequestMapping("/promotion/return/activityUser")
@RequiredArgsConstructor
public class ReturnActivityUserController {

    @Resource
    private ReturnActivityUserService returnActivityUserService;

    @ApiOperation(value = "查询用户全返卷")
    @GetMapping("/list")
    public ResultMessage<List<ReturnActivityUser>> getList(String useStatus) {
        AuthUser currentUser = Objects.requireNonNull(UserContext.getCurrentUser());
        return ResultUtil.data(returnActivityUserService.getList(currentUser.getExtendId(), useStatus));
    }

    @ApiOperation(value = "生成全返券")
    @GetMapping("/generate")
    public ResultMessage<Object> generate (String openId,String orderSn, Double price) {
        return returnActivityUserService.generate(openId, orderSn, price);
    }
}
